<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title>Excluir Animal</title>
        <link rel="stylesheet" href="../css/Tables.css" />
    </head>
    <body>
        
        <fieldset>
            <form>
                <label>Pesquisar Animal:</label>
                <input type="text" name="CampPesquisar" />
                <input type="button" name="pesquisar" value="Pesquisar" />
            </form>
        </fieldset>
        
        <?php
         require("../../_app/Config.inc.php");
         
         echo "<table><tr><th>Id</th><th>CPF Dono</th><th>Raça</th><th>Peso</th><th>Cor</th><th>Id Cliente</th><th>CPF Cliente</th><th>Excluir</th></tr>";
         $listar = new Read();
         $listar->ExeRead('animal');
         if ($listar->getResult()):
             foreach ($listar->getResult() as $lista):
                echo "<tr><td>{$lista['id_Animal']}</td><td>{$lista['CPF_Dono']}</td><td>{$lista['Raca_Animal']}</td><td>{$lista['Peso']}</td><td>{$lista['Cor_Pelo']}</td><td>{$lista['id_Cli']}</td><td>{$lista['CPF_Cli']}</td><td><a href=\"ExcluirAnimal.php?del={$lista['id_Animal']}\">Excluir</a></td></tr>";
             endforeach;
         endif;
         echo "</table>";
         
         if (!empty($_GET['del'])){
             $delete = $_GET['del'];
             
             $del = new Delete();
             $del->ExeDelete('animal', 'WHERE id_Animal=:delete', "delete={$delete}");
             
             if ($del->getResult()):
                echo "{$del->getRowCount()} registro(s) removidos com sucesso!";
            endif;
         }
             
        ?>
        
        
        
     
        
        
        
    </body>
</html>
